import db from '../../config/sqlcfg';
import { isUndefined } from 'util';

class EthConfig {

  private static table: string = 'eth_config';

  /**
   * 获取参数配置
   * @static
   * @param {string} param
   * @returns
   * @memberof EthConfig
   */
  static async getParam(param: string) {
    const raw = await db.query(`select value from ${this.table} where param = '${param}'  limit 1`);
    if(isUndefined(raw[0])){
      await Promise.reject(`数据库[${this.table}]表中[${param}]字段数据不存在`);
    }
    return raw[0].value;
  }

}

export default EthConfig;